# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# Author     ：skyTree
# version    ：python 3.11
# Description：fastapi主要配置文件
"""

import os
from dotenv import load_dotenv, find_dotenv
from pydantic_settings import BaseSettings
from typing import List


class Config(BaseSettings):
    # 加载环境变量
    load_dotenv(find_dotenv(), override=True)
    # 调试模式
    APP_DEBUG: bool
    # 项目信息
    APP_NAME: str
    APP_TITLE: str
    APP_VERSION: str
    APP_DESCRIPTION: str
    APP_HOST: str
    APP_PORT: int = 8002
    APP_RELOAD: str
    # 静态资源目录
    STATIC_DIR: str = os.path.join(os.getcwd(), "static")
    TEMPLATE_DIR: str = os.path.join(STATIC_DIR, "templates")
    # 数据库配置
    BASE_HOST: str
    BASE_PORT: str
    BASE_USER: str
    BASE_PASSWORD: str
    BASE_DB: str
    # 跨域请求
    CORS_ORIGINS: List = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List = ["*"]
    CORS_ALLOW_HEADERS: List = ["*"]
    # Session
    SECRET_KEY: str
    SESSION_COOKIE: str
    SESSION_MAX_AGE: int = 14 * 24 * 60 * 60
    # Jwt
    JWT_SECRET_KEY: str
    JWT_ALGORITHM: str
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24

    # 文档url
    APP_DOCS_URL: str
    APP_REDOC_URL: str
    SWAGGER_UI_OAUTH2_REDIRECT_URL: str = "/api/token"

    # 文件存储路径
    FILE_DIR: str = os.path.join(os.getcwd(), "files")

    # 允许上传文件的格式与大小
    FILE_ALLOWED_EXTENSIONS: List = ["image/png", "image/jpg", "image/jpeg"]
    FILE_MAX_FILE_SIZE: int = 1024 * 1024 * 4

    class Config:
        env_file: str = ".env"


settings = Config()
